<h1>文章列表</h1>

<% if(request[:notice] == 'successfully_created') %>
    <span class="label label-info" style="margin-bottom:10px;">发布成功</span>
<% elsif(request[:notice] == 'successfully_updated') %>
    <span class="label label-info" style="margin-bottom:10px;">修改成功</span>
<% end %>

<table class="table table-striped table-bordered table-condensed">
  <tr>
    <th>标题</th>
    <th>类别</th>
    <th>来源</th>
    <th>点击</th>
    <th>用户</th>
    <th>IP地址</th>
    <th>排序ID</th>
    <th>发布日期</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @posts.each do |post| %>
  <tr>
    <td><a href="/detail/<%=post.id%>.html" target="_blank"><%= post.title %></a>
        <% if(post.pic != nil and post.pic.length > 3) %>&nbsp;<i class="icon-picture"></i><% end %></td>
    <td><%=Common.getCateName post.cateid%></td>
    <td><%= post.source %></td>
    <td><%= post.hit %></td>
    <td><%= post.userid %></td>
    <td><%= post.userip %></td>
    <td><%= post.sortid %></td>
    <td style="<% if(post.postdate.in_time_zone(+8.hours) > Time.now.in_time_zone(+8.hours))%>color:red;<%end%>"><%= post.postdate.in_time_zone(+8.hours).strftime('%Y-%m-%d %H:%M:%S') %></td>
    <td><%= link_to 'Show', post %></td>
    <td><%= link_to 'Edit', edit_post_path(post) %></td>
    <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
  </tr>
<% end %>
</table>
<div class='flickr_pagination'><%= will_paginate @posts, :renderer => 'PostLinkRenderer', :previous_label => '上页', :next_label => '下页', :url => '/admin/pagelist/' %></div>
<br />

<%= link_to '新建文章', new_post_path %>

